package com.weiz.designpatterns.chainofresponsibility;

public class Supervisor implements LeaveRequestHandler {
    private LeaveRequestHandler nextHandler;

    @Override
    public void setNextHandler(LeaveRequestHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    @Override
    public void handleRequest(LeaveRequest request) {
        if (request.getDays() <= 3) {
            System.out.println("Supervisor approved the leave request.");
        } else if (nextHandler != null) {
            nextHandler.handleRequest(request);
        } else {
            System.out.println("No one can approve the leave request.");
        }
    }
}